﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Volo.Abp.Domain.Repositories;
using YunDrug.EmployeeAuthorization;

namespace YunDrug.Roles
{
   public  class UserRoleDomain
    {
        public UserRoleDomain(IRepository<Role, Guid> re_roles, IRepository<Employee , Guid> re_users, IRepository<EmployeeRole, Guid> re_userrole)
        {
            this.re_roles = re_roles;
            this.re_users = re_users;
            this.re_userrole = re_userrole;
        }

        public IRepository<Role,Guid> re_roles { get; set; }

        public IRepository<Employee ,Guid> re_users { get; set; }

        public IRepository<EmployeeRole,Guid> re_userrole { get; set; }

        public List<EmployeeRole> GetUserRoles(Guid userId,Guid roleId)
        {
            if (userId != null&&roleId==null)
            {
                return re_userrole.Where(p => p.EmployeeId.Equals(userId)).ToList();
            }
            else if(roleId!=null&& userId==null)
            {
                return re_userrole.Where(p => p.RoleId.Equals(roleId)).ToList();
            }
            else
            {
                return null;
            }
        }
    }
}
